<%@ Page Language="C#" AutoEventWireup="true" CodeFile="chatthairan.aspx.cs" Inherits="Telerik.GridExamplesCSharp.DataEditing.AllEditableColumns.tinhhinhxathai_chatthairan" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
     <style type="text/css">
        .MyImageButton
        {
           cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: #0066cc;
        }
        </style>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        
            <p id="divMsgs" runat="server">
        <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080"></asp:Label>
        <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000"></asp:Label>
            </p>
            
         <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

            <script type="text/javascript">
            function RowDblClick(sender, eventArgs)
            {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            </script>

        </telerik:RadCodeBlock>
        <!-- load ajax-->
         <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid_Xlsp">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid_XLsp" LoadingPanelID="RadAjaxLoadingPanel1" />
                    <telerik:AjaxUpdatedControl ControlID="divMsgs" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
        </telerik:RadAjaxManager>
        <!-- end-->
        
        
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" 
            BackColor="#99FF66" Skin="WebBlue" />
        <telerik:RadGrid ID="RadGrid_XLsp" runat="server" AllowPaging="True" 
            AllowSorting="True" CellSpacing="0" DataSourceID="SqlDataSource_sp1" 
            GridLines="None" AllowAutomaticDeletes="True" AutoGenerateColumns="False"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" OnItemUpdated="RadGrid_XLsp_ItemUpdated"
             
           OnItemInserted="RadGrid_XLsp_ItemInserted" OnDataBound="RadGrid_XLsp_DataBound" Skin="Telerik">
                <HeaderContextMenu></HeaderContextMenu>

                <MasterTableView AutoGenerateColumns="False" DataKeyNames="STT" 
                                DataSourceID="SqlDataSource_sp1" CommandItemDisplay="Top">
                                
                <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>

                <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>

    <Columns>
    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                        <ItemStyle CssClass="MyImageButton" />
                    </telerik:GridEditCommandColumn>
                    
        <telerik:GridBoundColumn DataField="STT" DataType="System.Int32"  Visible="false"
            FilterControlAltText="Filter STT column" HeaderText="STT" ReadOnly="True" 
            SortExpression="STT" UniqueName="STT">
        </telerik:GridBoundColumn>
        
           <telerik:GridTemplateColumn HeaderText="STT">
                       <ItemTemplate>
                        <asp:Label runat="server" ID="lblSTT" Text='<%#i++%>'></asp:Label>
                       </ItemTemplate>
           </telerik:GridTemplateColumn>
        
       
        
        <telerik:GridDropDownColumn DataField="Madnghiep" DataSourceID="sp_dn"
                        HeaderText="Doanhnghiep" ListTextField="TenDN" ListValueField="Madnghiep"
                        UniqueName="Madnghiep" ColumnEditorID="GridDropDownColumnEditor1">
        </telerik:GridDropDownColumn>
        
        <telerik:GridBoundColumn DataField="Chatthai" 
            FilterControlAltText="Filter Chatthai column" HeaderText="Chat thai" 
            SortExpression="Chatthai" UniqueName="Chatthai">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Nam" 
            FilterControlAltText="Filter Nam column" HeaderText="Nam" SortExpression="Nam" 
            UniqueName="Nam">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Thang" 
            FilterControlAltText="Filter Thang column" HeaderText="Thang" 
            SortExpression="Thang" UniqueName="Thang">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Tongkl" 
            FilterControlAltText="Filter Tongkl column" HeaderText="Tong khoi luong" 
            SortExpression="Tongkl" UniqueName="Tongkl">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Donvi" 
            FilterControlAltText="Filter Donvi column" HeaderText="Don vi" 
            SortExpression="Donvi" UniqueName="Donvi">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="Nguonphatsinh" 
            FilterControlAltText="Filter Nguonphatsinh column" HeaderText="Nguon phat sinh" 
            SortExpression="Nguonphatsinh" UniqueName="Nguonphatsinh">
        </telerik:GridBoundColumn>
        
        <telerik:GridBoundColumn DataField="Banra" 
            FilterControlAltText="Filter Banra column" HeaderText="Ban ra" 
            SortExpression="Banra" UniqueName="Banra">
        </telerik:GridBoundColumn>
        
        <telerik:GridBoundColumn DataField="Thaira" 
            FilterControlAltText="Filter Thaira column" HeaderText="Thai ra" 
            SortExpression="Thaira" UniqueName="Thaira">
        </telerik:GridBoundColumn>
        
        <telerik:GridBoundColumn DataField="Donvithumua" 
            FilterControlAltText="Filter Donvithumua column" HeaderText="Don vi thu mua" 
            SortExpression="Donvithumua" UniqueName="Donvithumua">
        </telerik:GridBoundColumn>
        
        <telerik:GridBoundColumn DataField="Dinhkythumua" 
            FilterControlAltText="Filter Dinhkythumua column" HeaderText="Dinh ky thu mua" 
            SortExpression="Dinhkythumua" UniqueName="Dinhkythumua">
        </telerik:GridBoundColumn>
        
        <telerik:GridButtonColumn ConfirmText="Delete this sanpham?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                        UniqueName="DeleteColumn">
                        <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                    </telerik:GridButtonColumn>
    </Columns>

            <EditFormSettings EditFormType="Template" ColumnNumber="2" CaptionDataField="Madnghiep" CaptionFormatString="Edit properties of Product {0}" InsertCaption="New Sanpham">
            
<EditColumn UniqueName="EditCommandColumn1" FilterControlAltText="Filter EditCommandColumn1 column"></EditColumn>
            
                <FormTemplate>
                
                    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;" >
                        <tr class="EditFormHeader">
                            <td colspan="2" style="font-size: small">
                                <b>Nhap thong tin: CHAT THAI RAN</b>
                            </td>
                        </tr>                      
                        
                             <tr>
                               <td>
                                <table id="Table3" cellspacing="1" cellpadding="1" width="100%" border="0" class="module">
                          <tr>
    <td>Doanh nghiep:</td>
    <td>
    <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("Madnghiep") %>'
DataTextField="TenDN" TabIndex="7" DataValueField="Madnghiep" DataSourceID="sp_dn" AppendDataBoundItems="True">
    <asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
    </asp:DropDownList>
    </td>
</tr>
<tr>
    <td>Chat thai:</td>
    <td>
     <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("Chatthai") %>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Nam:</td>
    <td>
        <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Nam") %>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Thang:</td>
    <td>
         <telerik:RadComboBox ID="cb_thang" runat="server" Skin="Hay" Text='<%# Bind("Thang") %>'>
                                                    <Items>
                                                        <telerik:RadComboBoxItem runat="server" Text="01" 
                                                            Value="01" />
                                                        <telerik:RadComboBoxItem runat="server" Text="02" 
                                                            Value="02" />
                                                        <telerik:RadComboBoxItem runat="server" Text="03" Value="03" />
                                                        <telerik:RadComboBoxItem runat="server" Text="04" 
                                                            Value="04" />
                                                        <telerik:RadComboBoxItem runat="server" Text="05" Value="05" />
                                                        <telerik:RadComboBoxItem runat="server" Text="06" 
                                                            Value="06" />
                                                        <telerik:RadComboBoxItem runat="server" Text="07 " Value="07 " />
                                                        <telerik:RadComboBoxItem runat="server" Text="08" Value="08" />
                                                        <telerik:RadComboBoxItem runat="server" Text="09" Value="09" />
                                                        <telerik:RadComboBoxItem runat="server" Selected="True" Text="10" 
                                                            Value="10" />
                                                            <telerik:RadComboBoxItem runat="server" Selected="True" Text="11" 
                                                            Value="11" />
                                                            <telerik:RadComboBoxItem runat="server" Selected="True" Text="12" 
                                                            Value="12" />
                                                    </Items>
                                                </telerik:RadComboBox>  
      </td>
</tr>
<tr>
    <td>Tong khoi luong:</td>
    <td>
        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("Tongkl") %>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Don vi:</td>
    <td>
    <asp:TextBox ID="TextBox10" runat="server" Text='<%# Bind("Donvi")%>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Nguon phat sinh:</td>
    <td>
        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("Nguonphatsinh") %>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Ban ra:</td>
    <td>
        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Banra") %>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Thai ra:</td>
    <td>
        <asp:TextBox ID="TextBox3" runat="server" Text='<%#Bind("Thaira") %>'></asp:TextBox></td>
</tr>
<tr>
    <td>Don vi thu mua:</td>
    <td>
        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Donvithumua") %>'></asp:TextBox>
    </td>
</tr>
<tr>
    <td>Dinh ky thu mua:</td>
    <td>
        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Dinhkythumua") %>'></asp:TextBox>
    </td>
</tr>
                                </table>
                            </td>
                          
                      
           
                            </tr>
                           
                        <tr>
                            <td align="right" colspan="2">
                                 <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button>&nbsp;
                                        <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                  
                                 
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
           </MasterTableView>
           <ClientSettings EnableRowHoverStyle="true">
               <Selecting AllowRowSelect="True" />
               <ClientEvents OnRowDblClick="RowDblClick" />
           </ClientSettings>


<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource_sp1" runat="server"
          ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" ProviderName="System.Data.SqlClient"
          SelectCommand="SELECT * from Chatthairan where Madnghiep=@Madnghiep"
           DeleteCommand="DELETE FROM [Chatthairan] WHERE [STT] = @original_STT"
           InsertCommand="INSERT INTO Chatthairan(Madnghiep, Chatthai,Nam,Thang,Tongkl,Donvi,Nguonphatsinh,Banra,Thaira,Donvithumua,Dinhkythumua) VALUES (@Madnghiep,@Chatthai,@Nam,@Thang,@Tongkl,@Donvi,@Nguonphatsinh,@Banra,@Thaira,@Donvithumua,@Dinhkythumua)"
           UpdateCommand="UPDATE [Chatthairan] SET [Madnghiep] = @Madnghiep, [Chatthai] = @Chatthai, [Nam] = @Nam, [Thang] = @Thang,[Tongkl]=@Tongkl,[Donvi]=@Donvi,[Nguonphatsinh]=@Nguonphatsinh,[Banra]=@Banra,[Thaira]=@Thaira,[Donvithumua]=@Donvithumua,[Dinhkythumua]=@Dinhkythumua WHERE [STT] = @original_STT"
           
          OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
         
          <SelectParameters>
        <asp:QueryStringParameter Name="Madnghiep" QueryStringField="_iddn"  ConvertEmptyStringToNull="true"/>
     </SelectParameters> 
          <DeleteParameters>
               <asp:Parameter Name="original_masp" Type="Int32" />
           </DeleteParameters>
           <UpdateParameters>
               <asp:Parameter Name="Madnghiep" Type="Int32" />
               <asp:Parameter Name="Chatthai" Type="String" />
               <asp:Parameter Name="Nam" Type="String" />
               <asp:Parameter Name="Thang" Type="String" />
               <asp:Parameter Name="Tongkl" Type="String" />
               <asp:Parameter Name="Donvi" Type="String" />
               <asp:Parameter Name="Nguonphatsinh" Type="String" />
                <asp:Parameter Name="Banra" Type="String" />
                 <asp:Parameter Name="Thaira" Type="String" />
                  <asp:Parameter Name="Donvithumua" Type="String" />
                  <asp:Parameter Name="Dinhkythumua" Type="String" />
               
               <asp:Parameter Name="original_STT" Type="Int32" />
               
               
           </UpdateParameters>
           <InsertParameters>                
               
               <asp:Parameter Name="Madnghiep" Type="Int32" />
               <asp:Parameter Name="Chatthai" Type="String" />
               <asp:Parameter Name="Nam" Type="String" />
               <asp:Parameter Name="Thang" Type="String" />
               <asp:Parameter Name="Tongkl" Type="String" />
               <asp:Parameter Name="Donvi" Type="String" />
               <asp:Parameter Name="Nguonphatsinh" Type="String" />
                <asp:Parameter Name="Banra" Type="String" />
                 <asp:Parameter Name="Thaira" Type="String" />
                  <asp:Parameter Name="Donvithumua" Type="String" />
                  <asp:Parameter Name="Dinhkythumua" Type="String" />
              
           </InsertParameters>
          
      </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource_XLsp" runat="server" 
            ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
            SelectCommand="SELECT [STT], [TenDN], [Chatthai], [Nam], [Thang], [Tongkl], [Donvi], [Nguonphatsinh],[Banra],[Thaira],[Donvithumua],[Dinhkythumua] FROM [Chatthairan]">
        </asp:SqlDataSource>
        
         <asp:SqlDataSource ID="sp_dn" runat="server" 
           ConnectionString="<%$ ConnectionStrings:QLMTConnectionString %>" 
           SelectCommand="SELECT * FROM [Doanhnghiep] where Madnghiep=@Madnghiep">
            <SelectParameters>
        <asp:QueryStringParameter Name="Madnghiep" QueryStringField="_iddn"  ConvertEmptyStringToNull="true"/>
     </SelectParameters>
         </asp:SqlDataSource>
        
               <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server" TextBoxStyle-Width="200px" />
       <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor2" runat="server" TextBoxStyle-Width="150px" />
       <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server" DropDownStyle-Width="110px" />
       <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server" NumericTextBox-Width="40px" />
    </div>
    </form>
</body>
</html>
